<template>
  <div>
    <n-bar></n-bar>
    <van-card
      v-for="item in goodslist"
      :key="item.id"
      :num="1"
      :price="item.price"
      :origin-price="item.market_price"
      :title="item.goodsname"
      class="goods-card"
      :thumb="item.img"
      @click='goDetail(item.id)'
    />
  </div>
</template>

<script>
import { getGoodlist } from "../request/app";
export default {
  data() {
    return {
      goodslist: [],
    };
  },
  mounted() {
    getGoodlist({
      cateid: this.$route.query.id,
    }).then((res) => {
      console.log(res, "二级分类列表");
      if (res.code == 200) {
        this.goodslist = res.list.goodData;
      }
    });
  },
  methods: {
    goDetail(id){
          // 跳转到商品详情页面 
          this.$router.push({
            path:'/detail',
            query:{
              id
            }
          })
    }
  },
};
</script>

<style scoped>
</style>
